//
//  Frame.swift
//  readtool
//
//  Created by WanJiading on 16/6/6.
//  Copyright © 2016年 DAD. All rights reserved.
//

import UIKit

extension UIView {
    var x: CGFloat {
        get {
            return self.frame.origin.x
        }
        set (newValue){
            self.frame.origin.x = newValue
        }
    }
    var y: CGFloat {
        get {
            return self.frame.origin.y
        }
        set (newValue){
            self.frame.origin.y = newValue
        }
    }
    var width: CGFloat {
        get {
            return self.frame.size.width
        }
        set (newValue){
            self.frame.size.width = newValue
        }
    }
    var height: CGFloat {
        get {
            return self.frame.size.height
        }
        set (newValue){
            self.frame.size.height = newValue
        }
    }
    var centerX: CGFloat {
        get {
            return self.center.x
        }
        set (newValue){
            self.center.x = newValue
        }
    }
    var centerY: CGFloat {
        get {
            return self.center.y
        }
        set (newValue){
            self.center.y = newValue
        }
    }
    var size: CGSize {
        get {
            return self.frame.size
        }
        set (newValue){
            self.frame.size = newValue
        }
    }
	
	/**
	获得当前 view 所在的ViewController
	*/
	func getCurrentViewController() -> UIViewController? {
		var next = self.next
		repeat {
			if next != nil {
				if ((next!.isKind(of: UIViewController.self))) {
					return next as? UIViewController
				}
			}
			next = next?.next
		} while (next != nil)
		
		return nil;
	}
	
	
}
